package com.jin.六大设计原则.里氏替换原则.顺从;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

//因为储蓄卡和信用卡都属于银行卡所以把他们的共同特点归纳到一个银行卡里面
//抽象类不能实例化
public abstract class BankCard {
    private Logger logger = LoggerFactory.getLogger(BankCard.class);
    private String cardNo;//卡号
    private String cardDate;//开卡时间

    public BankCard(String cardNo, String cardDate) {
        this.cardNo = cardNo;
        this.cardDate = cardDate;
    }

    //定义在抽象类中的抽象方法用来接收钱数
    abstract boolean rule(BigDecimal amount);
    //正向入帐，加钱（充钱）
    public String positive(String orderId,BigDecimal amount){
        //入款
        logger.info("卡号{} 入款成功,单号:{} 金额:{}",cardNo,orderId,amount);
        return "0000";
    }

    //逆向入账，减钱
    public String negative(String orderId,BigDecimal amount){
        //出款
        logger.info("卡号{} 出款成功,单号:{} 金额:{}",cardNo,orderId,amount);
        return "0000";
    }

    //交易流水查询
    public List<String> tradeFlow(){
        logger.info("交易流水查询成功");
        ArrayList<String> tradeList = new ArrayList<String>();
        tradeList.add("100001,100.00");
        tradeList.add("100001,80.00");
        tradeList.add("100001,76.00");
        tradeList.add("100001,126.00");
        return tradeList;
    }

    public String getCardNo() {
        return cardNo;
    }

    public String getCardDate() {
        return cardDate;
    }
}
